package com.fmync.ai.fmync.config;

import dev.langchain4j.model.ollama.OllamaStreamingChatModel;
import dev.langchain4j.model.ollama.spi.OllamaStreamingChatModelBuilderFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class MzOllamaStreamingChatModelBuilderFactory implements OllamaStreamingChatModelBuilderFactory {
    private final OllamaSystemProperties properties;
    @Override
    public OllamaStreamingChatModel.OllamaStreamingChatModelBuilder get() {
        MzChatModelProperties mzChatModelProperties = properties.getStreamingChatModel();
        return OllamaStreamingChatModel.builder().baseUrl(mzChatModelProperties.getBaseUrl())
                .modelName(mzChatModelProperties.getModelName())
                .temperature(mzChatModelProperties.getTemperature())
                .topK(mzChatModelProperties.getTopK())
                .topP(mzChatModelProperties.getTopP())
                .repeatPenalty(mzChatModelProperties.getRepeatPenalty())
                .seed(mzChatModelProperties.getSeed())
                .numPredict(mzChatModelProperties.getNumPredict())
                .timeout(mzChatModelProperties.getTimeout())
                .numCtx(2000);
    }
}
